package com.pool;

import java.beans.Statement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.naming.spi.DirStateFactory.Result;

public class MyConnection  {
	
	private Connection connection ; 
	
	private boolean isBusy;
	
	
	public MyConnection(Connection connection,boolean isBusy) {
		this.connection = connection;
		this.isBusy = isBusy;
	}
	

	public Connection getConnection() {
		return connection;
	}

	public void setConnection(Connection connection) {
		this.connection = connection;
	}

	public boolean isBusy() {
		return isBusy;
	}

	public void setBusy(boolean isBusy) {
		this.isBusy = isBusy;
	}
	
	public void close() {
		this.isBusy = false;
	}
	
	
	
	public ResultSet Query(String sql) {
		
		ResultSet resultSet = null;
		
		this.isBusy  = true;
		
		java.sql.Statement statement;
		
		try {
			statement = connection.createStatement();
			resultSet = statement.executeQuery(sql);
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		finally {
			this.isBusy=false;
		}
		 	return resultSet;
		
	}
	

	
	
	
	
}
